var util = require('../../util/util.js')
Page({
    onLoad:function(){
        var that = this;
        wx.showToast({
            title: '数据加载中',
            icon: 'loading'
        });
        wx.login({
            success: function (res) {
                wx.request({
                    url: 'https://admin.our-dream.cn/api/58fef28b2bfee',
                    data: {
                        code:res.code
                    },
                    method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
                    header: {
                        version:'v2.0',
                        agent:'wx',
                        'access-token': wx.getStorageSync('ApiAdminAccessToken')
                    },
                    success: function(res){
                        that.setData({
                            username:res.data.data.username,
                            password:res.data.data.password
                        })
                        wx.hideToast();
                    }
                });
            }
        });
    },
    data: {
        username:null,
        password:null
    },
    re: function () {
        var that = this;
        wx.showToast({
            title: '数据加载中',
            icon: 'loading'
        });
        wx.login({
            success: function (res) {
                wx.request({
                    url: 'https://admin.our-dream.cn/api/58fef525c55d2',
                    data: {
                        code:res.code
                    },
                    method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
                    header: {
                        version:'v2.0',
                        agent:'wx',
                        'access-token': wx.getStorageSync('ApiAdminAccessToken')
                    },
                    success: function(res){
                        that.setData({
                            username:res.data.data.username,
                            password:res.data.data.password
                        });
                        wx.hideToast();
                        wx.showToast({
                            title: '成功',
                            icon: 'success',
                            duration: 1000
                        })
                    }
                });
            }
        })
    }
});